<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>TZ-追梦</title>
    <style>
        * {
            margin: 0;
            padding: 0;
        }
    </style>
</head>
<body>
<input type="button" id="btn" value="生成">
<div id="box"></div>
<script>
    btn.onclick = function () {
        console.time(1);
        var num = 20000;
        var w = new Worker('worker2.js');
        w.postMessage(num);

        w.onmessage = function (e) {
            box.innerHTML= e.data;
        };

        console.timeEnd(1)
    }
</script>
</body>
</html>